package com.acoffee.controller;

import com.acoffee.pojo.MyDataSource;
import com.acoffee.pojo.MyPropertiesDataSource;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.web.bind.annotation.*;

import java.util.Date;

/**
 * @author acoffee
 * @create 2021-11-24 16:07
 */

@RestController
public class HelloController {

    @Value("${my-data-source.username}")
    String username;

    @Autowired
    MyDataSource myDataSource;

    @Autowired
    MyPropertiesDataSource myPropertiesDataSource;

    @RequestMapping("/hello")
    public String handleo1() {

        return "Hello,Spring Boot 2!";
    }

    @PostMapping("/testDate")
    @ResponseBody
    public String testDate(@RequestBody Date datetime) {
        return datetime.toString();
    }

    @RequestMapping("/myDataSource")
    public MyDataSource person() {

        return myDataSource;
    }
    @RequestMapping("/getUsername")
    public String  getUsername() {
        return username;
    }

    @RequestMapping("/myPropertiesDataSource")
    public MyPropertiesDataSource  getMyPropertiesDataSource() {
        return myPropertiesDataSource;
    }
}